package com.gusti.mensajes.util;

import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.GregorianCalendar;

/**
 * 
 * @author gusti
 *
 */
public class DateUtil {

	public static GregorianCalendar createDateTime() {
		Calendar calendar = Calendar.getInstance();
		calendar.add(Calendar.DAY_OF_MONTH, 0);
		calendar.add(Calendar.MONTH, 0);
		calendar.add(Calendar.YEAR, 0);
		calendar.add(Calendar.HOUR_OF_DAY, 0);
		calendar.add(Calendar.MINUTE, 0);
		calendar.add(Calendar.SECOND, 0);
		
		GregorianCalendar gregorianCalendar = new GregorianCalendar( calendar.get(Calendar.YEAR), calendar.get(Calendar.MONTH), calendar.get(Calendar.DAY_OF_MONTH), calendar.get(Calendar.HOUR_OF_DAY), calendar.get(Calendar.MINUTE), calendar.get(Calendar.SECOND) );
		
		return gregorianCalendar;
	}
	
	public static String getDate() {
		return getDate( Calendar.getInstance() );
	}
	
	public static String getDate( Calendar calendar ) {
		SimpleDateFormat simpleDateFormat = new SimpleDateFormat("dd/MM/yyyy");
		return simpleDateFormat.format( calendar.getTime() );
	}
	
	public static String getTime() {
		return getTime( Calendar.getInstance() );
	}
	
	public static String getTime( Calendar calendar ) {
		SimpleDateFormat simpleDateFormat = new SimpleDateFormat("HH:mm");
		return simpleDateFormat.format( calendar.getTime() );
	}

	public static String getDateTime() {
		return getDateTime( Calendar.getInstance() );
	}
	
	public static String getDateTime( Calendar calendar ) {
		SimpleDateFormat simpleDateFormat = new SimpleDateFormat("dd/MM/yyyy HH:mm:ss");
		return simpleDateFormat.format( calendar.getTime() );
	}

}
